//
//  BaseViewController.swift
//  JFDouYu
//
//  Created by xujf on 2018/1/8.
//  Copyright © 2018年 XuJF. All rights reserved.
//

import UIKit

class BaseViewController: UIViewController {

    var contentView : UIView?
    
    fileprivate lazy var animImageView : UIImageView = {
       [unowned self] in
        let imageView = UIImageView(image: UIImage(named: "img_loading_1"))
        imageView.center = view.center
        
        imageView.animationImages = [UIImage(named: "img_loading_1")!,UIImage(named: "img_loading_2")!]
        imageView.animationDuration = 0.5
        imageView.animationRepeatCount = LONG_MAX
        
        return imageView
        
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
    }
    
    func setupUI() {
        //1 隐藏内容的view
        contentView?.isHidden = true
        
        //2.添加执行动画的UIImageView
        view.addSubview(animImageView)
        //3.执行动画
        animImageView.startAnimating()
        //4 设置view 的北京颜色
        view.backgroundColor = UIColor(r: 250, g: 250, b: 250)
    }
}

extension BaseViewController {
   
    
    func loadDataFinished() {
        animImageView.stopAnimating()
        animImageView.isHidden = true
        contentView?.isHidden = false
    }
}
